package terra.network.packet.server;

import org.jboss.netty.buffer.ChannelBuffer;

import terra.network.packet.Packet;

public class NpcInfo extends Packet {

	public float x,y;
	public int w,h;
	public int hp,maxHp;
	public int oId;
	public int id;
	
	public NpcInfo() {
	}

	@Override
	public ChannelBuffer toBuffer() {
		ChannelBuffer buf = getNewBuffer();
		buf.writeByte(getId());		
		buf.writeInt(oId);	
		buf.writeInt(id);
		buf.writeFloat(x);
		buf.writeFloat(y);	
		buf.writeInt(w);	
		buf.writeInt(h);
		buf.writeInt(hp);	
		buf.writeInt(maxHp);
		return buf;
	}

	@Override
	public Packet fromBuffer(ChannelBuffer buf) {
		oId = buf.readInt();
		id = buf.readInt();		
		x = buf.readFloat();
		y = buf.readFloat();
		w = buf.readInt();
		h = buf.readInt();
		hp = buf.readInt();
		maxHp = buf.readInt();
		return this;
	}

	@Override
	public int getLength() {
		return 33;
	}

	@Override
	public boolean isDynamicLength() {
		return false;
	}

	@Override
	public byte getId() {
		return 14;
	}
	
	@Override
	public byte getPriority() {
		return PRIOR_NORMAL;
	}

}
